" append pdf to the end of the file extension {{{1
function! AppendPdfToFileNameFunction()
  " wrapping is evil
  set nowrap
  " remove everything but file lines
  v/^-/d
  " remove excessive ls information
  g/./normal 8daW
  " wrap in double quote
  g/./normal g0i"
  g/./normal g$a"
  " fix rear
  g/./normal yypg$i.pdfjlkJ
  " fix front
  g/./normal Imv jl
  " output fish script
  write! /tmp/vim-gen-appendpdftofilename.fish
  " quit
  q!
endfunction

" remove pdf from the end of the file extension {{{1
function! RemovePdfFromFileNameFunction()
  " wrapping is evil
  set nowrap
  " remove everything but file lines
  v/^-/d
  " remove dir
  g/^d/d
  " remove lines that don't end with .(acceptable actual file extension).pdf
  v/\v\.(pdf|ape|sub|srt|cue|mp3|mp4|avi|zip|rar|gz|svg|wav|mov|m4a|m4v|rmvb|flv|wmv|wma|iso|mkv|\d\d\d)\.pdf$/d
  " remove excessive ls information
  g/./normal 8daW
  " wrap in double quote
  g/./normal g0I"
  g/./normal g$A"
  " fix rear
  g/./normal yypg$XXXXkJ
  " fix front
  g/./normal Imv jl
  " output fish script
  write! /tmp/vim-gen-removepdffromfilename.fish
  " quit
  q!
endfunction

" remove single quotes from file name {{{1
function! RemoveSingleQuoteFromFileNameFunction()
  " wrapping is evil
  set nowrap
  " remove stats line
  d
  " remove excessive ls information
  g/./normal 8daW
  " cannot deal with double quotes
  g/"/d
  " remove lines that don't have single quotes
  v/'/d
  " apply double quotes
  g/./normal g0I"
  g/./normal g$A"
  " helper cmap
  cnoremap \zcr <cr>
  " replace single quotes with spaces
  g/./normal yyp:s/'/ /\zcrkJ
  " fix head
  g/./normal imv jl
  " output fish script
  write! /tmp/vim-gen-removeSingleQuoteFromFileName.fish
  " quit
  q!
endfunction

" removeSingleQuoteFromFileName must be run before this {{{1
function! DoThisToFileNameFunction()
  " wrapping is evil
  set nowrap
  " ls all files
  r!ls
  " read string commands and clear head
  normal gg
  r /tmp/doThisToFileName
  normal ggdd
  normal Inormal jl
  normal 0"py$
  normal dd
  " wrap in single quotes
  g/./normal i'
  g/./normal g$a'
  " map <cr>
  cnoremap \zcr <cr>
  " duplicate file name and run the command
  g/./normal yypg0l:@p\zcrkJ
  " fix head
  g/./normal imv jl
  " output fish script
  saveas! /tmp/vim-gen-doThisToFileName.fish
  " quit
  q!
endfunction
